package day1106;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class ArrayListAndLinkedList {
    public static void main(String[] args) {
        ArrayList list=new ArrayList();
        double start=System.nanoTime();
        for (int i=0;i<100000;i++){
            list.add(new Integer(i));
        }
        double end=System.nanoTime();
        System.out.println(end-start+"纳秒");

        //删除
        double start2=System.nanoTime();
        for (int i=0;i<100;i++){
            int index=(int)Math.random()*10000;
            list.remove(new Integer(i));
        }
        double end2=System.nanoTime();
        System.out.println(end2-start2+"纳秒");

        LinkedList list1=new LinkedList();
        double start1=System.nanoTime();
        for(int i=0;i<100000;i++){
            list1.add(new Integer(i));
        }
        double end1=System.nanoTime();
        System.out.println(end1-start1+"纳秒");

        //随机删除
        double start3=System.nanoTime();
        for(int i=0;i<100;i++){
            int index1=(int)Math.random()*10000;
            list1.remove(new Integer(i));
        }
        double end3=System.nanoTime();
        System.out.println(end3-start3+"纳秒");
    }
}
